package com.mc.web.controller.fil;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mc.common.annotation.Log;
import com.mc.common.core.controller.BaseController;
import com.mc.common.core.domain.AjaxResult;
import com.mc.common.enums.BusinessType;
import com.mc.fil.domain.FilWeeding;
import com.mc.fil.service.IFilWeedingService;
import com.mc.common.utils.poi.ExcelUtil;
import com.mc.common.core.page.TableDataInfo;

/**
 * 除草 Controller
 *
 * @author mc
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/fil/weeding")
public class FilWeedingController extends BaseController
{
    @Autowired
    private IFilWeedingService filWeedingService;

    /**
     * 查询除草 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:weeding:list')")
    @GetMapping("/list")
    public TableDataInfo list(FilWeeding filWeeding)
    {
        startPage();
        List<FilWeeding> list = filWeedingService.selectFilWeedingList(filWeeding);
        return getDataTable(list);
    }

    /**
     * 导出除草 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:weeding:export')")
    @Log(title = "除草 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FilWeeding filWeeding)
    {
        List<FilWeeding> list = filWeedingService.selectFilWeedingList(filWeeding);
        ExcelUtil<FilWeeding> util = new ExcelUtil<FilWeeding>(FilWeeding.class);
        return util.exportExcel(list, "weeding");
    }

    /**
     * 获取除草 详细信息
     */
    @PreAuthorize("@ss.hasPermi('fil:weeding:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(filWeedingService.selectFilWeedingById(id));
    }

    /**
     * 新增除草
     */
    @PreAuthorize("@ss.hasPermi('fil:weeding:add')")
    @Log(title = "除草 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FilWeeding filWeeding)
    {
        return toAjax(filWeedingService.insertFilWeeding(filWeeding));
    }

}
